﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CodeCamp.Controllers
{
  internal static class SponsorsHelper
  {
    private const float maxImageWidth = 200;
    private const float maxImageHeight = 100;
    private const float aspectOfMaxImage = maxImageHeight / maxImageWidth;

    internal class ImageSize
    {
      public int Width;
      public int Height;
    }

    internal static ImageSize GetScaledImageSize( int width, int height )
    {
      float aspectOfImage = ( (float)height ) / width;
      float scale = aspectOfImage >= aspectOfMaxImage
        ? maxImageHeight / height       // height limited
        : maxImageWidth / width;        // width limited

      return new ImageSize
      {
        Width = (int)Math.Floor( width * scale ),
        Height = (int)Math.Floor( height * scale )
      };
    }


  }
}